/**
 * Created by Administrator on 2016/9/5.
 */
//Start warterfall
$(window).load(function() {
    var length = $("#wtLi").length

    var clientHeight = window.innerHeight;

    //console.log(scrollTop);
    //console.log(clientHeight);
    var config = [
        {"src":"images/waterfall-2.jpg","title":"盘点80后新人另类婚纱摄影风格","main":"80后婚纱照风格有哪些?目前，婚纱摄影在短短几年时间，发生了天翻地覆的变化。而婚纱照的流行风格也从传统婚纱照向个性时尚的风格转变。随...","time":"POST TIME : 2016 - 9 -5"},
        {"src":"images/waterfall-3.jpg","title":"胖女孩婚纱照风格解析","main":"胖女孩婚纱照风格解析。人人都想在拍婚纱照的时候拍出美丽的自己，但是身材比较胖的女生总是会担心自己拍的婚纱照会不会很难看，那么胖女孩...","time":"POST TIME : 2017 - 9 -8"},
        {"src":"images/waterfall-4.jpg","title":"新人服装与拍摄场景如何完美结合","main":"两个完全不认识的人能走到一起，从相识、相恋，最后走进婚姻的殿堂，这是一件很神圣的事情，拍一套美美的照片，给自己的爱情留下最美好的回...","time":"POST TIME : 2018 - 9 -5"},
        {"src":"images/waterfall-5.jpg","title":"2016年流行什么婚纱照风格-三类","main":"婚纱摄影风格花样繁多，准新人们也一定会为自己的婚纱照要拍什么样的风格而纠结，要找一家适合自己的婚纱摄影工作室，还要选到适合自己风格...","time":"POST TIME : 2019 - 9 -5"},
        {"src":"images/waterfall-6.jpg","title":"什么样的新娘妆适合重庆拍婚纱摄影","main":"随着韩剧热潮的刮起，新人们对韩式婚纱照的热情有增无减。剧中很多人物的造型同样被设计到了2016婚纱礼服的流行款式中，当然其中新娘们最关...","time":"POST TIME : 2020 - 9 -5"},
        {"src":"images/waterfall-7.jpg","title":"如何选择重庆新娘婚纱照礼服头纱","main":"头纱带给人们的神秘感绝不亚于任何一场世界级的魔术表演。因为准新娘们都是第一次接触重庆婚纱照的拍摄，所以对于拍摄当中要用到的道具，它...","time":"POST TIME : 2021 - 9 -5"},
        {"src":"images/waterfall-8.jpg","title":"拍婚纱照怎样缓解紧张情绪","main":"新人第一次拍婚纱照面对镜头多少都会觉得有点紧张，一旦紧张拍出来的婚纱照就会很僵硬，因此新人拍婚纱照一定要尽快克服紧张情绪哦！下面就...","time":"POST TIME : 2016 - 7 -5"},
        {"src":"images/waterfall-9.jpg","title":"重庆哪家的婚纱摄影比较好呢，人流..","main":"现在结婚的新人是非常多的，新人会选择在这个季节拍自己的婚纱照，但是此时户外的天气是非常冷的，很多新人都不知道应该去哪里拍自己的婚纱...","time":"POST TIME : 2016 - 9 -1"},
        {"src":"images/waterfall-1.jpg","title":"重庆婚纱照哪里拍摄的最好，效果...","main":"新人的美丽不仅只是外表的美丽，新人的美丽往往还会从她们的心里绽放出来，许多的新人为什么有时候拍摄婚纱照会非常的漂亮呢，有时候拍摄的...","time":"POST TIME : 2016 - 9 -4"}
    ]

    $(window).scroll(function(){
        var scrollTop = $(window).scrollTop();
        var LastImageTop = $("#wtLi")[length - 1].offsetTop;
        //console.log(scrollTop);
        if(scrollTop <= "5000"){
            var arr = [];
            if(LastImageTop < clientHeight + scrollTop){
                for(var i = 0 ;i < config.length ; i++){
                    var str = "<li>" +
                        "<a href='javascript:void(0);'>" +
                        "<img src='"+config[i].src+"'>" +
                        "<p class='wtTitle'>"+config[i].title+"</p>" +
                        "<p class='wtMain'>"+config[i].main+"</p>" +
                        "<p>"+config[i].time+"<i></i></p>" +
                        "</a>" +
                        "</li>"
                    arr.push(str);
                }
                arr = arr.join("");
                $(".waterfall>ul").append(arr);
        }


        }
    })
    $(".waterfall>ul").on("mouseenter","li",function(){
        $(this).css("backgroundColor","#FFDE00").siblings().css("backgroundColor","#F0F0F0");
    }).on("mouseleave","li",function(){
        $(".waterfall>ul>li").css("backgroundColor","#F0F0F0");
    })

//End waterfall
//Start carousel
    Interval();
    $(".carousel").on("mouseenter",function(){
        $(".carouselArr").animate({opacity:"1"},200)
        clearInterval(timerId);
    }).on("mouseleave",function(){
        $(".carouselArr").animate({opacity:"0"},200);
        Interval();
    })
    var str = [
        {zIndex:"5",width: "900px",top: "0px",left:"150px",opacity:"1"},
        {zIndex:"1",width: "700px",top: "60px",left:"820px",opacity:"0.8"},
        {zIndex:"0",width: "600px",top: "95px",left:"750px",opacity:"0.2"},
        {zIndex:"0",width: "500px",top: "60px",left:"350px",opacity:"0.5"},
        {zIndex:"0",width: "600px",top: "95px",left:"-150px",opacity:"0.2"},
        {zIndex:"1",width: "700px",top: "60px",left:"-300px",opacity:"0.8"},
    ];
    assign();
    var flag =true ;
    $(".arrRight").on("click",function(){
        if(flag){
            flag = false;
        str.push(str.shift());
        assign();
        }
    });
    $(".arrLeft").on("click",function(){
        if(flag){
            flag = false;
            str.unshift(str.pop());
            assign();
        }
    })
    function assign (){
        for(var i = 0 ;i < str.length ; i++){
            $(".carousel li").eq(i).animate(str[i],500,function(){
                flag = true;
            });
        }
    }
    var timerId;
    function Interval(){
        clearInterval(timerId);
        timerId = setInterval(function(){
            str.push(str.shift());
            assign();
        },2000);
    }
//start cover
    $(".cover ul").on("mouseenter","li",function(){
        $(this).find("s").stop().animate({height:"450px",opacity:"1"},300).end().siblings().find("s").stop().animate({height:"0px",opacity:"0"},300);
        $(this).find("p").stop().css({color:"#29c8c3"}).end().siblings().find("p").stop().css({color:"#000"});
    })
    $(".cover ul").on("mouseleave",function(){
        $(this).find("s").animate({height:"0px",opacity:"0"},300);
        $(this).find("p").css({color:"#000"});
    })
})